import { post, get, _delete, put } from '@/lin/plugin/axios'

class Unit {
  static async addUnit(data) {
    const res = await post('v1/ag/unit/create', data)
    return res
  }

  static async getUnit(id) {
    const res = await get(`v1/ag/unit/${id}`)
    return res
  }

  static async getUnitList() {
    const res = await get(`v1/ag/unit/list`)
    return res
  }

  static async editUnit(id, data) {
    const res = await put(`/v1/ag/unit/${id}`, data)
    return res
  }

  static async deleteUnit(id) {
    const res = await _delete(`/v1/ag/unit/${id}`)
    return res
  }

  static async getUnits(page = 0, count = 10) {
    const res = await get('/v1/ag/unit/page', { page, count })
    return res
  }

  // static async getUnitList() {
  //   const res = await get('/v1/ag/unit/list')
  //   return res
  // }
  static async search({ keyword, page, count }) {
    const res = await get('v1/ag/unit/search', {
      keyword,
      page,
      count,
    })
    return res
  }
}

export default Unit
